
package com.probiz.estore.common.service.impl;

import com.probiz.estore.common.model.sales.GiftCertificate;
import com.probiz.estore.common.service.GiftCertificateService;
import com.probiz.estore.exception.GiftCertificateStateException;
import com.probiz.estore.sales.service.GiftCertificateManager;

public class GiftCertificateServiceImpl implements GiftCertificateService {

	private GiftCertificateManager	giftCertificateManager;

	public void setGiftCertificateManager(GiftCertificateManager giftCertificateManager) {
		this.giftCertificateManager = giftCertificateManager;
	}
	/*
	 * (non-Javadoc)
	 * @see com.probiz.estore.common.service.GiftCertificateService#doSendGiftCertificate(com.probiz.estore.common.model.sales.GiftCertificate, java.lang.String)
	 */
	public void doSendGiftCertificate(GiftCertificate giftCertificate, String orderNo) {
		// 将状态设为激活
		giftCertificate.setStatus(GiftCertificate.STATUS_ACTIVE);
		if (null != orderNo && !orderNo.equals("")) {
			giftCertificate.setOrderNo(orderNo);
		}
		giftCertificateManager.save(giftCertificate);
		giftCertificateManager.sendGiftCertificate(giftCertificate, orderNo);
	}
	/*
	 * (non-Javadoc)
	 * @see com.probiz.estore.common.service.GiftCertificateService#queryGiftCertificateByNo(java.lang.String)
	 */
	public GiftCertificate queryGiftCertificateByNo(String giftCertificateNo) {
		GiftCertificate giftCertificate = giftCertificateManager.getGiftCertificate(giftCertificateNo);
		return giftCertificate;
	}
	/*
	 * (non-Javadoc)
	 * @see com.probiz.estore.common.service.GiftCertificateService#checkGiftcertificate(java.lang.String)
	 */
	public void checkGiftcertificate(String giftCertificateNo) throws GiftCertificateStateException {
		giftCertificateManager.checkGiftcertificate(giftCertificateNo);
	}
	/*
	 * (non-Javadoc)
	 * @see com.probiz.estore.common.service.GiftCertificateService#getGiftCertificateByNo(java.lang.String)
	 */
	public GiftCertificate getGiftCertificateByNo(String giftCertificateNo) {
		return giftCertificateManager.getGiftCertificate(giftCertificateNo);
	}
}
